# 用于访问限制的装饰器
from flask import g
from functools import wraps


def login_required(f):
    @wraps(f)
    def warpper(*args, **kwargs):
        if g.user_id:
            return f(*args, **kwargs)
        else:
            return {"message": "Invalid Token", "data": None}, 401

    return warpper
